<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('图纸设备查看')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <p>文件编码：</p>
                            <input type="text" name="fileCode"/>
                        </li>
                        <li>
                            <p>文件名称：</p>
                            <input type="text" name="fileName"/>
                        </li>
                        <li>
                            <p>版本：</p>
                            <input type="text" name="version"/>
                        </li>
                        <li>
                            <p>版次：</p>
                            <input type="text" name="edition"/>
                        </li>

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var fenGe = "%FGF%";
    var editFlag = [[${@permission.hasPermi('docContentPargraph:doc:edit')}]];
    var prefix = ctx + "docContentPargraph/operating/doc";
    var httpUrl = [[${httpUrl}]];
    $(function() {
        var options = {
            url: prefix + "/list",
            modalName: "dxf文件索引信息",
            columns: [
                // {
                //     checkbox: true
                // },
                {
                    title: "序号",
                    //width : '30%',
                    formatter: function (value, row, index) {
                        return $.table.serialNumber(index);
                    }
                },
                {
                    field : 'id',
                    title : '文件id',
                    visible: false
                },
                {
                    field : 'fileCode',
                    title : '文件编码'
                },
                {
                    field : 'fileName',
                    title : '文件名称'
                },
                {
                    field : 'fileVersion',
                    title : '版本'
                },
                {
                    field : 'edition',
                    title : '版次'
                },
                {
                    field : 'fileType',
                    title : '类型'
                },
                {
                    field : 'remark',
                    title : '状态',
                    formatter: function(value, row, index){
                        if (value==null || value=='') return '成功';
                        let split = value.split(fenGe);
                        if (split[0]=='异常') return "<span style='background-color: yellow'>"+ handleFg(value) + "</span>";
                        if (split[0]=='失败') return "<span style='background-color: red'>"+ handleFg(value) + "</span>";
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        // actions.push('<a class="btn btn-success btn-xs' + searchFlag + '" href="javascript:void(0)" onclick="searchDraw(\'' + row.fileId + '\' , \''+ row.status + '\')"><i class="fa fa-edit"></i>查看数据</a> ');
                        // actions.push('&nbsp;&nbsp;<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="edit(\'' + row.fileId + '\')"><i class="fa fa-edit"></i>查看J</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href='+ httpUrl +'/?id='+row.id+ ' target="_blank"><i class="fa fa-edit"></i>查看</a> ');
                        // actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href='+ httpUrl +'/id/'+row.id+ ' target="_blank"><i class="fa fa-edit"></i>查看</a> ');
                        actions.push('&nbsp;<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');

                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });


    function handleFg(data) {

        while (data.indexOf(fenGe)!=-1) {
            data = data.replace(fenGe, "");
        }

        return data;
    }


</script>
</body>
</html>